﻿
using System.Collections;
using Microsoft.AspNetCore.Mvc;
using Estsh.Core.Services.IServices;
using Estsh.Core.Model.Result;
using Estsh.Core.Controllers;
using Estsh.Core.Util;


namespace Estsh.Core.Web.Controllers
{

    /// <summary>
    /// 收货查询补打模块的控制类
    /// </summary>
    [Area("wms")]
    public class StockBarcodePrintController : BaseController
    {
        private IStockBarcodePrintService service;
        private ICommonService commonService;
        public StockBarcodePrintController(IStockBarcodePrintService _service, ICommonService _commonService)
        {
            service = _service;
            this.commonService = _commonService;

        }
        public ActionResult Index()
        {
            return View();
        }

        #region 收货查询补打

        /// <summary>
        /// 根据分页条件获取用户列表
        /// </summary>
        /// <param name="account"></param>
        /// <param name="pager"></param>
        /// <param name="direction"></param>
        /// <param name="sort"></param>
        /// <returns></returns>
        public ActionResult getListByPage(string cartonNo, string refOrderNo, string status, string lotno, string locateId, string zoneId, string beginCreateTime, string endCreateTime, 
                                            Pager pager, String direction, String sort)
        {
            int factoryId = CurrentEmp.FactoryId;

            Hashtable result = new Hashtable();
            result.Add("pager.pageNo", pager.pageNo);
            Hashtable dataHt = this.service.getListByPage(cartonNo, refOrderNo, status,lotno, locateId, zoneId, beginCreateTime, endCreateTime, factoryId, pager, direction, sort);
            result.Add("rows", dataHt["dataList"]);
            result.Add("pager.totalRows", dataHt["totalCount"]);
            result.Add("sort", sort);
            result.Add("direction", direction);
            return Json(result);
        }

        /// <summary>
        /// 获取库存状态列表
        /// </summary>
        /// <returns></returns>
        public ActionResult getStockStatus()
        {
            Hashtable result = new Hashtable();
            List<KeyValueResult> list = commonService.GetSysEnum("sys_stock_status");
            result.Add("list", list);
            return Json(result);
        }

        /// <summary>
        /// 获取库位列表
        /// </summary>
        /// <returns></returns>
        public ActionResult getLocateList()
        {
            Hashtable result = new Hashtable();
            List<KeyValueResult> list = this.service.getLocateList();
            result.Add("list", list);
            return Json(result);
        }
        /// <summary>
        /// 获取库区列表
        /// </summary>
        /// <returns></returns>
        public ActionResult getZoneList()
        {
            Hashtable result = new Hashtable();
            List<KeyValueResult> list = this.service.getZoneList();
            result.Add("list", list);
            return Json(result);
        }

        /// <summary>
        /// 打印
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        public ActionResult print(String ids)
        {
            String message = "";
            try
            {
                message = this.service.print(ids);
            }
            catch (Exception e)
            {
                message = "Controller：" + e.Message;
            }
            Hashtable result = new Hashtable();
            result.Add("status", message);
            return Json(result);
        }

        #endregion
    }
}
